package com.code.apollo.utils;

import java.io.File;
import java.util.List;

/**
 * <Description>
 * 文件工具类
 * @author Jun Lee
 * @version 1.0
 * @createDate 2020/03/16 21:31
 * @see com.code.apollo.utils
 */
public class FileUtil {

    public static void searchAllFile(File file, List list) {
        for (File temp : file.listFiles()) {
            if (temp.isDirectory()) {
                searchAllFile(temp,list);
            }else if (temp.isFile()){
                list.add(temp);
            }
        }
    }

    //创建文件
    public static File mkdir(String dir,String file) {
        if(dir == null) throw new IllegalArgumentException("dir must be not null");
        File result = new File(dir,file);
        if (result.exists()) {
            result.delete();
        }
        if(result.getParentFile() != null) {
            result.getParentFile().mkdirs();
        }
        return result;
    }


}
